<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${naviString}</title>
<link href="${ctx}/commons/styles/themes/blue/styles/style.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/commons/scripts/jquery-ui/themes/redmond/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center">
  <div align="left" style="width:99%">
    <div align="left" class="nav">${naviString}</div>
    <html-el:form action="/manager/BrandIntroduce.do" enctype="multipart/form-data">
      <html-el:hidden property="method" value="save" />
      <html-el:hidden property="mod_id" />
      <html-el:hidden property="id" />
      <br />
      <table width="100%" border="0" align="left" cellpadding="1" cellspacing="1" class="datagrid">
        <tr>
          <th colspan="2">品牌介绍</th>
        </tr>
        <tr>
          <td width="15%" class="title_item"><span style="color: #F00;">*</span><strong>主标题：</strong></td>
          <td width="85%"><html-el:text property="title" styleId="title" maxlength="30" style="width:480px" />
            主标题颜色:
            <html-el:select property="title_color">
              <html-el:option value="">默认</html-el:option>
              <html-el:option value="000000" style="background-color:#000000">&nbsp;</html-el:option>
              <html-el:option value="FFFFFF" style="background-color:#FFFFFF">&nbsp;</html-el:option>
              <html-el:option value="008000" style="background-color:#008000">&nbsp;</html-el:option>
              <html-el:option value="800000" style="background-color:#800000">&nbsp;</html-el:option>
              <html-el:option value="808000" style="background-color:#808000">&nbsp;</html-el:option>
              <html-el:option value="000080" style="background-color:#000080">&nbsp;</html-el:option>
              <html-el:option value="800080" style="background-color:#800080">&nbsp;</html-el:option>
              <html-el:option value="808080" style="background-color:#808080">&nbsp;</html-el:option>
              <html-el:option value="FFFF00" style="background-color:#FFFF00">&nbsp;</html-el:option>
              <html-el:option value="00FF00" style="background-color:#00FF00">&nbsp;</html-el:option>
              <html-el:option value="00FFFF" style="background-color:#00FFFF">&nbsp;</html-el:option>
              <html-el:option value="FF00FF" style="background-color:#FF00FF">&nbsp;</html-el:option>
              <html-el:option value="FF0000" style="background-color:#FF0000">&nbsp;</html-el:option>
              <html-el:option value="0000FF" style="background-color:#0000FF">&nbsp;</html-el:option>
              <html-el:option value="008080" style="background-color:#008080">&nbsp;</html-el:option>
            </html-el:select></td>
        </tr>
        <tr>
          <td class="title_item"><strong>副标题：</strong></td>
          <td><html-el:text property="sub_title" maxlength="50" style="width:480px" /></td>
        </tr>
        <tr>
          <td class="title_item"><strong>主图图片：</strong></td>
          <td><c:if test="${not empty (hf.map.accessory.save_url)}" var="hasImage" ><br/>
              <img src="${ctx}/${hf.map.accessory.save_url}" title="${hf.map.accessory.file_name}" /><br />
              <input type="checkbox" name="chkReUploadImage" id="chkReUploadImage" value="1" onclick="$('#save_url').toggle();" />
              <label for="chkReUplhfdImage">重新上传主图</label>
              <br/>
              <html-el:file property="save_url" style="display:none;width:500px;" styleId="save_url" />
            </c:if>
            <c:if test="${empty (hf.map.accessory.save_url)}">
              <html-el:file property="save_url" style="width:500px;" />
            </c:if>
            <div>上传的主图会自动缩放成合适的尺寸</div></td>
        </tr>
        <tr>
          <td class="title_item"><strong>主图说明：</strong></td>
          <td><html-el:text property="description" maxlength="120" style="width:480px" />
            <html-el:hidden property="acce_id" value="${hf.map.accessory.id}" /></td>
        </tr>
        <tr>
          <td class="title_item"><span style="color: #F00;">*</span><strong>内容：</strong></td>
          <td><FCK:editor instanceName="content">
              <jsp:attribute name="value">${hf.map.content}</jsp:attribute>
            </FCK:editor>
            <div>1、此处上传的图片不会自动缩放，请用相关做图软件缩放成您想要的大小或手动调整大小！</div>
            <div>2、点击最后一排倒数第三个按钮可实现全屏编辑</div></td>
        </tr>
        <tr>
          <td class="title_item"><span style="color: #F00;">*</span><strong>信息状态：</strong></td>
          <td><html-el:select property="info_state" styleId="info_state" value="${hf.map.info_state}">
              <html-el:option value="">请选择...</html-el:option>
              <c:forEach var="cur" items="${infoStateList}">
              	<html-el:option value="${cur.dictionary_value}">${cur.dictionary_desc_cn}</html-el:option>
              </c:forEach>
            </html-el:select></td>
        </tr>
        <tr>
          <td class="title_item">&nbsp;</td>
          <td><html-el:button property="save" value=" 保 存 " styleId="save" styleClass="ui-state-default ui-corner-all" style="cursor:pointer;" />&nbsp;
            <html-el:reset value=" 重 填 " styleClass="ui-state-default ui-corner-all" style="cursor:pointer;" />
            &nbsp;&nbsp; <span id="loading" style="display:none;"><img src="${ctx}/commons/styles/images/loading.gif" style="vertical-align:middle; margin: 2px;" />数据提交中，请稍候...</span></td>
        </tr>
      </table>
    </html-el:form>
  </div>
</div>
<script type="text/javascript" src="${ctx}/commons/scripts/validator.js"></script>
<script type="text/javascript" src="${ctx}/commons/scripts/jquery.js"></script>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	initStyle();
	
	$("#title").attr("datatype","Require").attr("msg","主标题必须填写");
	$("#info_state").attr("datatype","Require").attr("msg","信息状态必须选择");
		
	var f = document.forms[0];
	$("#save").click(function(){
		if($("#chkReUploadImage").attr("checked") == true || "${hasImage}" == "false"){
			$("#save_url").attr("datatype","Require").attr("msg","网点图片必须上传");
		}else{
			$("#save_url").removeAttr("datatype").removeAttr("msg");
		}
		
		if(Validator.Validate(f, 1)) {
			var content = getFCKBody("content");
			if($.trim(content.text()) == "" || content.text() == null){
				alert("内容必须填写");
				content.focus();
				return false;
			}
			
			$("#loading").show();
			$("#save").attr("disabled", "true");
			$("#reset").attr("disabled", "true");

			f.submit();
		}
	});
});

function getFCKBody(name){
	var iframe_document = $("#" + name + "___Frame",document).get(0).contentWindow.document;
	var xEditingArea = $("#xEditingArea",iframe_document);
	var content = $("iframe",xEditingArea).get(0).contentWindow.document;

	return $(content).find("body");
}

function initStyle(){
	$("input[type='text']").css({border: "1px solid #ccc"});
	$("input[type='submit'],input[type='reset'],input[type='button']").css({border: "1px solid"});
	$("input[type='text'][readonly],input[type='password'][readonly],textarea[readonly]").css({color:"#000"});
    $("input[type='text'],input[type='password'],textarea").not("[readonly]").focus(function(){
    	$(this).addClass("row_focus");
    }).blur(function(){
    	$(this).removeClass("row_focus");
    });
    
	$("textarea").each(function(){
		this.onpropertychange = function () {
			if (this.scrollHeight > 16) this.style.posHeight = this.scrollHeight;
		};
	});
}

function setOnlyNum() {
	$(this).css("ime-mode", "disabled").attr("t_value", "").attr("o_value", "").bind("dragenter",function(){
		return false;
	});
	$(this).keypress(function (){
		if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value;
	}).keyup(function (){
		if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value;
	}).blur(function (){
		if(!this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/))this.value=this.o_value;else{if(this.value.match(/^\.\d+$/))this.value=0+this.value;if(this.value.match(/^\.$/))this.value=0;this.o_value=this.value;}
		if(this.value.length == 0) this.value = "0";
	});
	//this.text.selected;
}


//]]></script>
</body>
</html>
